package org.elasticsearch.rescore;

import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;

import java.net.URI;

/**
 * @author shenfl
 * 读取elasticsearch配置
 */
public class Config {
    public static final Setting<String> REDIS_URL = new Setting<String>("redisRescore.redisUrl", "localhost", v -> {
        try {
            new URI(v);
            return v;
        } catch (Exception e) {
            throw new IllegalArgumentException("Setting is not a valid URI");
        }
    }, Setting.Property.NodeScope, Setting.Property.Dynamic);

    private final String redisUrl;

    public Config(final Settings settings) {
        this.redisUrl = REDIS_URL.get(settings);
    }

    public String getRedisUrl() {
        return redisUrl;
    }
}